package com.modules.system.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.modules.system.dao.SysUserRoleDao;
import com.modules.system.service.SysUserRoleService;
import java.util.List;


/**
 * 用户与角色对应关系
 * 
 */
@Service("sysUserRoleService")
public class SysUserRoleServiceImpl implements SysUserRoleService {
	@Autowired
	private SysUserRoleDao sysUserRoleDao;

	@Override
	public void saveOrUpdate(Long userId, List<Long> roleIdList) {
		if(roleIdList.size() == 0){
			return ;
		}
		//先删除用户与角色关系
		sysUserRoleDao.deleteByUserId(userId);
		//保存用户与角色关系
		sysUserRoleDao.save(userId,roleIdList);
	}

	@Override
	public List<Long> getRoleIdList(Long userId) {
		return sysUserRoleDao.getRoleIdList(userId);
	}

	@Override
	public void delete(Long userId) {
		sysUserRoleDao.deleteByUserId(userId);
	}
}
